#include "MeshAsset.h"

std::tuple<std::vector<uint8_t>, size_t> YXX_AS::MeshAsset::GenRasterizeData() const
{
	assert((positions.size() == normals.size()) && 
		(positions.size() == uv.size()) && 
		!positions.empty());

	size_t num = positions.size();
	std::vector<uint8_t> vertexBuffer;

	size_t stride = 0;
	stride += sizeof(positions[0]);
	stride += sizeof(normals[0]);
	stride += sizeof(uv[0]);

	vertexBuffer.resize(stride * num);

	size_t offset = 0;
	uint8_t* data = vertexBuffer.data();
	for (size_t i = 0;i < num;i ++)
	{
		memcpy(data + offset, positions[i].data(), sizeof(positions[i]));
		offset += sizeof(positions[i]);

		memcpy(data + offset, normals[i].data(), sizeof(normals[i]));
		offset += sizeof(normals[i]);

		memcpy(data + offset, uv[i].data(), sizeof(uv[i]));
		offset += sizeof(uv[i]);
	}

	return { vertexBuffer,stride };
}
